/**
 * @name 服务管理
 */
import http from "@/api";
import { ReqPage } from "@/api/interface";
import { System } from "@/api/interface/iot";

// 服务列表
export const serviceList = (params: ReqPage) => {
	return http.get<System.ResServer[]>(`/service/find`, params, { headers: { noLoading: true } });
};
export const serviceDetail = (params: { id?: string; instanceId?: string }) => {
	return http.get<System.ResServer>(`/service/get`, params);
};
// 上传程序（通用接口）
// export const serviceUpload = (param: FormData) => {
// 	return http.post(`/service/bin/upload`, param);
// };
// 启动服务
export const serviceStart = (param: { id?: string; instanceId?: string }) => {
	return http.post(`/service/start`, param);
};
// 停止服务
export const serviceStop = (param: { id?: string; instanceId?: string }) => {
	return http.post(`/service/stop`, param);
};
// 停止服务
export const serviceRemove = (param: any) => {
	return http.post(`/service/remove`, param);
};
// 服务升級
export const serviceUpdate = (param: any) => {
	return http.post(`/service/bin/update`, param);
};
// 服务升級
export const serviceUpgrade = (param: any) => {
	return http.post(`/service/upgrade`, param);
};
// 添加服务
export const serviceAdd = (params: any) => {
	return http.post(`/service/add`, params);
};
// 添加服务
export const serviceMod = (params: any) => {
	return http.post(`/service/modify`, params);
};
// 获取服务日志
export const serviceLog = (params: { id: string; lines?: number }) => {
	return http.get(`/service/proc/log/get`, params);
};
// 应用添加节点
export const serviceNodeAdd = (params: any) => {
	return http.post(`/service/app/node/add`, params);
};
// 应用删除节点
export const serviceNodeRemove = (params: any) => {
	return http.post(`/service/app/node/remove`, params);
};
// 应用节点列表
export const serviceNodeList = (params: any) => {
	return http.get<any>(`/service/app/node/find`, params);
};
